package gucas.ac.cn.IRproject.index;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.Date;

public class ThreadIndexer implements Runnable {
	
	private File indexDir ;
	private File dataDir;
	private boolean runstatus = false;
	
	public ThreadIndexer(File indexD, File dataD) {
		indexDir = indexD;
		dataDir = dataD;
		
	}
	public void run(){
		long start = new Date().getTime();
	    indexer conIndex = new indexer(indexDir,dataDir);;
		int numIndexed = 0;
		try {
			numIndexed = conIndex.index(indexDir,dataDir);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} //3890
		//int numIndexed = index(indexDir,dataDir); //3813ms
		long end = new Date().getTime();
		System.out.println("Indexing " + numIndexed + " files took:" + (end-start) + " milliseconds");
	
	runstatus = true;
	}
	public void stop(){
	runstatus = true;	
	}
	public boolean getStatus(){
		return runstatus;
	}
}
